#include <stdio.h>

int nums[10];


void input(){
    scanf("%d %d %d %d %d %d %d %d %d %d", &nums[0], &nums[1], &nums[2], &nums[3], &nums[4], &nums[5], &nums[6], &nums[7], &nums[8], &nums[9]);
}

void handle(){
    int max,min,minIndex=0,maxIndex=0;
    min = nums[0];
    max = nums[9];
    
    //查看是否有比min小的数字
    for (size_t i = 0; i<10; i++)
    {
        if(nums[i]<min){
            min = nums[i];
            minIndex = i;
        }
    }
    nums[minIndex] = nums[0];
    nums[0] = min;

    //10 9 8 7 6 5 4 1 3 2
    for (size_t i = 0; i < 10; i++)
    {
        if(nums[i]>max){
            max = nums[i];
            maxIndex = i;
        }
    }
    nums[maxIndex] = nums[9];
    nums[9] = max;
    

    


    
}

void output(){
    for (size_t i = 0; i < 10; i++)
    {
        printf("%d ", nums[i]);
    }
}


int main(int argc, char *argv[]) {
    
    input();
    handle();
    output();

    return 0;
}